/**
 * Created with IntelliJ IDEA.
 * User: ajhin
 * Date: 6/23/13
 * Time: 11:56 PM
 * To change this template use File | Settings | File Templates.
 */
package societyGames.document.xmlContainerCommand
{
import mx.events.CollectionEvent;
import mx.events.CollectionEventKind;
import mx.events.PropertyChangeEvent;

import societyGames.document.model.CommandStack;
import societyGames.xmlFragment.XMLChangedEvent;
import societyGames.xmlFragment.XMLContainer;

public class CommandGenerator
{
  private var _commandStack:CommandStack;

  public function CommandGenerator(xmlContainer:XMLContainer, commandStack:CommandStack)
  {
    _commandStack = commandStack;
    xmlContainer.addEventListener(XMLContainer.CHANGED, onModulesContainerChanged);
  }


  private function onModulesContainerChanged(event:XMLChangedEvent):void
  {
    trace(event);
    var collectionEvent:CollectionEvent = event.collectionEvent;
    if (collectionEvent.kind == CollectionEventKind.UPDATE)
    {
      //TODO: Make a property change command.
      var propertyChangeEvent:PropertyChangeEvent = PropertyChangeEvent(collectionEvent.items[0]);
      propertyChangeEvent.kind == CollectionEventKind.UPDATE;
      propertyChangeEvent.newValue;
      propertyChangeEvent.oldValue;
      propertyChangeEvent.property;
      propertyChangeEvent.source;
    }
  }
}
}
